package com.company.app.entities;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

import com.google.code.ssm.api.CacheKeyMethod;

/**
 * The Class ProductType.
 */
/**
 * @author projas
 * 
 */
@XmlType(namespace = "http://entities.app.company.com", propOrder = { "id",
		"name", "description", "dateCreated", "products" })
@XmlRootElement(name = "ProductType")
public class ProductType implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 7539525618988621625L;

	/** The id. */
	private Long id;

	/** The name. */
	private String name;

	/** The description. */
	private String description;

	/** The date created. */
	private Date dateCreated;

	/** The products. */
	private List<Product> products;

	/**
	 * Gets the id.
	 * 
	 * @return the id
	 */
	public Long getId() {
		return id;
	}

	/**
	 * Sets the id.
	 * 
	 * @param id
	 *            the new id
	 */
	public void setId(Long id) {
		this.id = id;
	}

	/**
	 * Gets the name.
	 * 
	 * @return the name
	 */
	@XmlElement(required = true)
	public String getName() {
		return name;
	}

	/**
	 * Sets the name.
	 * 
	 * @param name
	 *            the new name
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * Gets the description.
	 * 
	 * @return the description
	 */
	@XmlElement(required = true)
	public String getDescription() {
		return description;
	}

	/**
	 * Sets the description.
	 * 
	 * @param description
	 *            the new description
	 */
	public void setDescription(String description) {
		this.description = description;
	}

	/**
	 * Gets the date created.
	 * 
	 * @return the date created
	 */
	@XmlElement(required = false)
	public Date getDateCreated() {
		return dateCreated;
	}

	/**
	 * Sets the date created.
	 * 
	 * @param dateCreated
	 *            the new date created
	 */
	public void setDateCreated(Date dateCreated) {
		this.dateCreated = dateCreated;
	}

	/**
	 * Gets the products.
	 * 
	 * @return the products
	 */
	public List<Product> getProducts() {
		return products;
	}

	/**
	 * Sets the products.
	 * 
	 * @param products
	 *            the new products
	 */
	public void setProducts(List<Product> products) {
		this.products = products;
	}

	/*
	 * (non-Javadoc) Also used to generate MEMCACHED key
	 * 
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return "ProductType{id:" + this.getId() + ", name:" + this.getName()
				+ ", description:" + this.getDescription() + ", dateCreated:"
				+ this.getDateCreated() + "}";
	}

	/*
	 * Gets the cache id.
	 * 
	 * @return the cache id
	 */
	@CacheKeyMethod
	public String getIdForCache() {
		return this.getId() != null ? this.getId().toString() : "NULL";
	}

}
